Skip to contentSkip to conversation

Change in openvpn[master]: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr

Openvpn-devel In review flichtenheld (Code Review) 2 participants 9 messages Oct 21, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1761063467000.I76babf08b041162ddedf7a9b7c2799847f15cbdc@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email

to review the following change.

Change subject: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr
......................................................................

multi: Fix wrong usage of mroute_extract_openvpn_sockaddr

maddr.proto needs to be set before the call since that will change the behavior.

Found by GCC "'maddr.proto' is used uninitialized"

Change-Id I76babf08b041162ddedf7a9b7c2799847f15cbdc

---
M src/openvpn/multi.c
M src/openvpn/push.c
M src/openvpn/ssl_verify.c

3 files changed, 16 insertions(+), 20 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1292/1

src/openvpn/multi.c +1 -1
index e907524..fa9c654 100644
@@ -3965,9 +3965,9 @@
     saddr.addr.in4.sin_family = AF_INET;
     saddr.addr.in4.sin_addr.s_addr = htonl(addr);
     saddr.addr.in4.sin_port = htons(port);
+    maddr.proto = proto;
     if (mroute_extract_openvpn_sockaddr(&maddr, &saddr, true))
     {
-        maddr.proto = proto;
         hash_iterator_init(m->iter, &hi);
         while ((he = hash_iterator_next(&hi)))
         {
src/openvpn/push.c +11 -6
index 2c717c7..1871816 100644
@@ -429,11 +429,6 @@
     gc_free(&gc);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 bool
 send_auth_pending_messages(struct tls_multi *tls_multi, struct tls_session *session,
                            const char *extra, unsigned int timeout)
@@ -449,7 +444,12 @@
     /* Calculate the maximum timeout and subtract the time we already waited */
     unsigned int max_timeout =
         max_uint(tls_multi->opt.renegotiate_seconds / 2, tls_multi->opt.handshake_window);
-    max_timeout = max_timeout - (now - ks->initial);
+    time_t time_elapsed = now - ks->initial;
+    if (time_elapsed < 0 || time_elapsed >= (time_t)max_timeout)
+    {
+        return false;
+    }
+    max_timeout -= (unsigned int)time_elapsed;
     timeout = min_uint(max_timeout, timeout);
 
     struct gc_arena gc = gc_new();
@@ -734,6 +734,11 @@
     return true;
 }
 
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
 static bool
 send_push_options(struct context *c, struct buffer *buf, struct push_list *push_list, int safe_cap,
                   bool *push_sent, bool *multi_push)
src/openvpn/ssl_verify.c +4 -13
index 04ef27e..fe95621 100644
@@ -874,11 +874,6 @@
     return supported;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 /**
  *  Checks if the deferred state should also send auth pending
  *  request to the client. Also removes the auth_pending control file
@@ -915,8 +910,9 @@
             buf_chomp(iv_buf);
             buf_chomp(extra_buf);
 
+            errno = 0;
             long timeout = strtol(BSTR(timeout_buf), NULL, 10);
-            if (timeout == 0)
+            if (timeout <= 0 || timeout > UINT_MAX || errno)
             {
                 msg(M_WARN, "could not parse auth pending file timeout");
                 buffer_list_free(lines);
@@ -933,14 +929,13 @@
                          pending_method);
                 auth_set_client_reason(multi, buf);
                 msg(M_INFO,
-                    "Client does not supported auth pending method "
-                    "'%s'",
+                    "Client does not supported auth pending method '%s'",
                     pending_method);
                 ret = false;
             }
             else
             {
-                send_auth_pending_messages(multi, session, BSTR(extra_buf), timeout);
+                send_auth_pending_messages(multi, session, BSTR(extra_buf), (unsigned int)timeout);
             }
         }
 
@@ -950,10 +945,6 @@
     return ret;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 /**
  *  Removes auth_pending and auth_control files from file system
  *  and key_state structure
Signature · 13 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76babf08b041162ddedf7a9b7c2799847f15cbdc
Gerrit-Change-Number: 1292
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email

to look at the new patch set (#2).

Change subject: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr
......................................................................

multi: Fix wrong usage of mroute_extract_openvpn_sockaddr

maddr.proto needs to be set before the call since that will change the behavior.

Found by GCC "'maddr.proto' is used uninitialized"

Change-Id I76babf08b041162ddedf7a9b7c2799847f15cbdc

---
M src/openvpn/multi.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1292/2

src/openvpn/multi.c +1 -1
index e907524..fa9c654 100644
@@ -3965,9 +3965,9 @@
     saddr.addr.in4.sin_family = AF_INET;
     saddr.addr.in4.sin_addr.s_addr = htonl(addr);
     saddr.addr.in4.sin_port = htons(port);
+    maddr.proto = proto;
     if (mroute_extract_openvpn_sockaddr(&maddr, &saddr, true))
     {
-        maddr.proto = proto;
         hash_iterator_init(m->iter, &hi);
         while ((he = hash_iterator_next(&hi)))
         {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76babf08b041162ddedf7a9b7c2799847f15cbdc
Gerrit-Change-Number: 1292
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

its_Giaan has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email )

Change subject: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr
......................................................................

Patch Set 2: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76babf08b041162ddedf7a9b7c2799847f15cbdc
Gerrit-Change-Number: 1292
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: its_Giaan <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 21 Oct 2025 17:35:41 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email )

Change subject: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr
......................................................................

Patch Set 2: Code-Review-2

(1 comment)

Patchset:

PS2:
v2 has some stuff in there that doesn't belong here (push.c, ssl_verify.c integers)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76babf08b041162ddedf7a9b7c2799847f15cbdc
Gerrit-Change-Number: 1292
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: its_Giaan <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 21 Oct 2025 19:30:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email )

Change subject: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr
......................................................................

Patch Set 2: Code-Review+2

(1 comment)

Patchset:

PS2:
Oh, sorry. That was a gerrit comparison artefact.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76babf08b041162ddedf7a9b7c2799847f15cbdc
Gerrit-Change-Number: 1292
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: its_Giaan <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 21 Oct 2025 19:31:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#6 lore raw

PATCH v2 1/1 multi: Fix wrong usage of mroute_extract_openvpn_sockaddr

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

maddr.proto needs to be set before the call since that will change the behavior.

Found by GCC "'maddr.proto' is used uninitialized"

Change-Id I76babf08b041162ddedf7a9b7c2799847f15cbdc

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1292
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1292
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
Gianmarco De Gregori <[email protected]...>

src/openvpn/multi.c +1 -1
index e907524..fa9c654 100644
@@ -3965,9 +3965,9 @@
     saddr.addr.in4.sin_family = AF_INET;
     saddr.addr.in4.sin_addr.s_addr = htonl(addr);
     saddr.addr.in4.sin_port = htons(port);
+    maddr.proto = proto;
     if (mroute_extract_openvpn_sockaddr(&maddr, &saddr, true))
     {
-        maddr.proto = proto;
         hash_iterator_init(m->iter, &hi);
         while ((he = hash_iterator_next(&hi)))
         {
#7 lore raw

[Openvpn-devel] [PATCH applied] Re: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr

Bad API hack, correct fix... verified by going to mroute.c and reading up on what mroute_extract_openvpn_sockaddr() does with "addr.proto" which should be an *output* structure, but this field is used as input as well... can someone fix this for good, please, after 2.7 release?

(Quite an impressive find by GCC)

Your patch has been applied to the master branch.

commit 0abf6e716b5a50b2b7f4287b1d50f4889eed36aa

Author: Frank Lichtenheld
Date:   Tue Oct 21 21:31:40 2025 +0200
     multi: Fix wrong usage of mroute_extract_openvpn_sockaddr

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Acked-by: Gianmarco De Gregori <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1292
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33830.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#8 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2, Code-Review+2 by its_Giaan

Change subject: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr
......................................................................

multi: Fix wrong usage of mroute_extract_openvpn_sockaddr

maddr.proto needs to be set before the call since that will change the behavior.

Found by GCC "'maddr.proto' is used uninitialized"

Change-Id I76babf08b041162ddedf7a9b7c2799847f15cbdc

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1292
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33830.html

---
M src/openvpn/multi.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1292/3

src/openvpn/multi.c +1 -1
index e907524..fa9c654 100644
@@ -3965,9 +3965,9 @@
     saddr.addr.in4.sin_family = AF_INET;
     saddr.addr.in4.sin_addr.s_addr = htonl(addr);
     saddr.addr.in4.sin_port = htons(port);
+    maddr.proto = proto;
     if (mroute_extract_openvpn_sockaddr(&maddr, &saddr, true))
     {
-        maddr.proto = proto;
         hash_iterator_init(m->iter, &hi);
         while ((he = hash_iterator_next(&hi)))
         {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76babf08b041162ddedf7a9b7c2799847f15cbdc
Gerrit-Change-Number: 1292
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: its_Giaan <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#9 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email )

Change subject: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr
......................................................................

multi: Fix wrong usage of mroute_extract_openvpn_sockaddr

maddr.proto needs to be set before the call since that will change the behavior.

Found by GCC "'maddr.proto' is used uninitialized"

Change-Id I76babf08b041162ddedf7a9b7c2799847f15cbdc

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1292
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33830.html

---
M src/openvpn/multi.c

1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/multi.c +1 -1
index e907524..fa9c654 100644
@@ -3965,9 +3965,9 @@
     saddr.addr.in4.sin_family = AF_INET;
     saddr.addr.in4.sin_addr.s_addr = htonl(addr);
     saddr.addr.in4.sin_port = htons(port);
+    maddr.proto = proto;
     if (mroute_extract_openvpn_sockaddr(&maddr, &saddr, true))
     {
-        maddr.proto = proto;
         hash_iterator_init(m->iter, &hi);
         while ((he = hash_iterator_next(&hi)))
         {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1292?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76babf08b041162ddedf7a9b7c2799847f15cbdc
Gerrit-Change-Number: 1292
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: its_Giaan <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>